package com.zhouchb.stream;

import java.io.*;

/**
 * @Author Zhouchb
 * @Create 2021-11-2021/11/1 :10:42
 * @Description
 */
public class BufferReaderWriter {
    public static void main(String[] args) {
        test();
    }
    public static void test(){
        BufferedReader br = null;
        BufferedWriter bw = null;
        try {
            br = new BufferedReader(new FileReader(new File("IO/Hello.txt")));
            bw = new BufferedWriter(new FileWriter(new File("IO/Hello2.txt")));
            String data;
            while ((data=br.readLine())!=null){
               // bw.write(data+"\n");
                bw.write(data);
                bw.newLine(); //换行
            }
        } catch (IOException e) {
            e.printStackTrace();
        } finally {
            try {
                if (br!=null)
                br.close();
            } catch (IOException e) {
                e.printStackTrace();
            }
            try {
                if (bw!=null)
                bw.close();
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
    }
}
